<template>
  <a-modal :visible="show" title="批量调价" @cancel="cancel" :width="800" :footer="null">
    <a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol">
      <a-form-model-item label="出价调整">
        <a-input-number v-model="form.y" style="width: 360px;" /> %
      </a-form-model-item>
      <a-form-model-item :wrapper-col="{ span: 14, offset: 1 }">
        <a-button type="primary" :loading="loading" @click="handleOk">
          提交
        </a-button>
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import { batchRaiseOcpcBid as raiseOcpcBid } from '@/api/dianshang/dianshang'
export default {
  props: {
    show: Boolean,
    taskId: [String, Number],
  },
  data() {
    return {
      labelCol: { span: 3 },
      wrapperCol: { span: 14 },
      form: {
        y: 0,
      },
      loading: false,
    }
  },
  created() {
  },
  methods: {
    getData() {
    },
    handleOk() {
      const params = Object.assign(this.form, {
        task_id: this.taskId,
      })
      this.loading = true
      raiseOcpcBid(params).then((res) => {
        this.loading = false
        if (res.errcode == 0) {
          // this.cancel()
          this.$message.success('设置成功')
          this.close()
        }
      }).catch(() => {
        this.loading = false
      });
    },
    close() {
      this.$emit('update:show', false)
    },
    cancel() {
      this.$emit('update:show', false)
    }
  },
  filters: {
    getStatus(status) {
      switch (status) {
        case 0:
        case '0':
          return '未执行'
        case 1:
        case '1':
          return '已执行'
      }
    }
  },
  watch: {
    show(status) {
      if (status) {
        this.getData()
        this.form = {
          y: 0,
        }
      }
    }
  },
}
</script>